---
layout : default
title : Phoenix Documentation
---
@model Pretzel.Logic.Templating.Context.PageContext

#Phoenix MVVM + C Framework

Phoenix is a MVVM and MVC Hybrid framework, the goal is to address the shortcomings of MVVM frameworks and make WPF and WP7 development much nicer (hopefully WinRT too soon). The shortcomings we address are:

 - Overly complex viewmodels, which deal with data manipulation, view concerns, and often are a mix of business logic and model transformation so it can be bound using MVVM.
 - A mix of background threads and UI threads with runtime exceptions when you get it wrong
 - Often very low cohesion and high coupling to multiple model sources (WCF services, or Rest)

The way Phoenix does this is by introducing a controller. This means:

 - ViewModels are UI thread only, anything that requires running off the UI thread belongs in a Controller Action.
 - By introducing a controller, logical operations can be grouped together in a controller, meaning controllers have very high cohesion
 
 Phoenix also has been designed from the ground up to heavily rely on TPL and has full and native support for the new async/await keywords, which means Phoenix will help you write responsive asynchronous applications really easily!

## Overview

Like ASP.net, Phoenix resolves controllers and views based on conventions. ViewModels are passed to the PageActionResult, so they can be placed anywhere.
Controllers simply have to end with 'Controller' to be discovered, views are more flexible, but it is recommended you use this structure:

 * Controllers
    * HomeController.cs
 * ViewModels
    * Home
        * IndexViewModel.cs
        * SomeViewModel.cs
        * AnotherViewModel.cs
 * Views
    * Home
	   * Index.xaml
	   * SomePage.xaml
	   * AnotherView.xaml

Or

 * Features
    * Home
       * HomeController.cs
       * Index.xaml
       * Index.vm.cs
       * SomePage.xaml
       * SomePage.vm.cs
       * AnotherView.xaml
       * AnotherView.vm.cs
       
Other layouts should be supported out of the box. With the second layout, I recommend using VS Commands to group the viewmodel as a codebehind file just like Index.xaml.cs, keeping the view and viewmodel together.

**Home.Index** is the default controller action in Phoenix, if you have multiple assemblies with the same views/controller names you can qualify the controller action by using a 'Assembly;Controller.Action' syntax.

## MVC / MVVM Separation
The first thing I need to clarify is that Phoenix is ALSO a MVVM Framework. The MVC component is for fetching data, doing background work, showing dialogs or performing navigation. Interaction within a single view is all done using MVVM. Think about ASP.net MVC, the client side html/javascript will invoke controller actions to fetch additional data, or navigate to a URL which invokes the controller action. Things are slightly different in the rich client world, but conceptually similar.

Read more about [Controllers](docs\Controllers.html) or [View Models](docs\ViewModels.html) in Phoenix.

## Features
 - Full Support for async/await keywords and asynchronous controller actions
 - [Event Aggregation](docs\EventAggregator.html)
 - [Filter Support](docs\Filters.html) (Action Filters, Result Filters and Exception Filters). Filters can be used for all sorts of things, you could even introduce Caliburn Micro style conventions and wireup with a Result filter!
 - Simple and efficient type safe (navigate with Lambda's) [navigation](docs\Navigation.html) between views in WPF and WP7
 - WP7 [Tombstoning and lifecycle](docs\Lifecycle.html) support, simple as Transient(()=>MyProperty) to mark that property as something that should survive tombstoning
 - Memory Saving Mode - Allows views/viewmodels in the back stack to be garbage collected, saving state, when the user navigates back, if that view has been GC'd, Phoenix will re-execute the controller action, and restore state.
 - [Transition](docs\Transitions.html) support for both WP7 and WPF. WPF is included in the main package, WP7 is in an extension as it relies on the Silverlight for Windows Phone Toolkit.
 - Partial views and nested [navigation frames](docs\NavigationFrames.html) - Allowing you to nest views without injecting other views into your viewmodels, helps to really decouple your UI and make it more reusable and modular.
 - Simple error handling & built in error reporter for WP7.
 - [Hostable](docs\HostingPhoenix.html) - Allowing you to use Phoenix just for a single view/section of your application (a wizard/navigation heavy view?). 
 - Extension to add autofac support ([IoC Support](docs\IoC.html) not required by default)
 
## Documentation Topics

[**Getting Started**](docs\GettingStarted.html)  
[**Controllers**](docs\Controllers.html)  
[**Filters**](docs\Filters.html) - ActionFilters, ResultFilters and Exception filters allow you to cross cut concerns, and introduce simple AOP style development  
[**View Models**](docs\ViewModels.html)  
[**WP7 Tombstoning Support**](docs\Lifecycle.html)  
[**NavigationFrames**](docs\NavigationFrames.html)  
[**Hosting Phoenix**](docs\HostingPhoenix.html) - Use Phoenix in a single view, instead of your entire application  
[**Transitions Support**](docs\Transitions.html)  
[**IoC Support**](docs\IoC.html)  
[**EventAggregator**](docs\EventAggregator.html)